package vn.fsoft.gst.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import vn.fsoft.gst.dao.DepartmentDAO;
import vn.fsoft.gst.domain.Department;

/**
 * 
 * @author Tung
 *
 */

@Service
public class DepartmentServiceImp implements DepartmentService{
    
	@Autowired
	private DepartmentDAO departmentDAO;
	
	@Transactional
	public Integer addDepartment(Department object) {
		Integer id = (int) departmentDAO.addDepartment(object);
		return id;
	}
	
	@Transactional
	public List<Department> getListDepartment() {
		return departmentDAO.getListDepartment();
	}
	
	@Transactional
	public int editDepartment(Department object) {
		int rowEffect = 0;
		
		rowEffect = departmentDAO.editDepartment(object);
		
		return rowEffect;
	}
	
	@Transactional
	public Department getDepartmentById(int id) {
		Department department = null;
		
		department = departmentDAO.getDepartmentById(id);
		
		return department;
	}
	
	@Transactional
	public int markActiveDepartment(int departmentId) {
		return departmentDAO.markActiveById(departmentId);
	}
	
	@Transactional
	public List<Department> getListDepartmentByDirecId(int id) {
		return departmentDAO.getListDepartmentByDirecId(id);
	}
	
	@Transactional
	public int markInActiveDepartment(int departmentId) {
		return departmentDAO.markInActiveById(departmentId);
	}
	
	@Transactional 
	public boolean checkUniqueName(String departmentName) {
		return departmentDAO.checkUniqueName(departmentName);
	}
}
